package com.cloudsigns.factorymanager2.project.presenter;

import com.cloudsigns.factorymanager2.project.iview.ISurveyOrderSendForManagerView;
import com.cloudsigns.factorymanager2.project.model.ISurveyOrderSendForManagerModel;
import com.cloudsigns.factorymanager2.project.model.SurveyOrderSendForManagerModel;

/**
 * Created by tony on 2018/8/5.
 */

public class SurveyOrderSendForManagerPresenter {
    private ISurveyOrderSendForManagerView view;
    private ISurveyOrderSendForManagerModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public SurveyOrderSendForManagerPresenter(ISurveyOrderSendForManagerView view) {
        this.view = view;
        this.model = new SurveyOrderSendForManagerModel();
    }

    public void surveyOrderSendForManager() {


        model.surveyOrderSendForManager(view.getId(), view.getReceiveAccountId(), new  SurveyOrderSendForManagerModel.OnSurveyOrderSendForManagerListener() {
            @Override
            public void surveyOrderSendForManagerSuccessed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.surveyOrderSendForManagerSuccess();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void surveyOrderSendForManagerFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.surveyOrderSendForManagerFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
